package com.jds.test.bio.p12;

/**
 * https://www.cnblogs.com/silyvin/articles/12078621.html
 * https://www.cnblogs.com/silyvin/articles/12083466.html
 * Created by joyce on 2019/11/26.
 */
public class Client {

    public static void main(String [] f) throws InterruptedException {
        Client client = new Client();
        run();
        Client.zuse();
    }

    /**
     * print tcp 4059 稳定
     * print file 1 不稳定
     * lsof -p 13152|wc -l 4635 不稳定
     * @throws InterruptedException
     */
    public static void run() throws InterruptedException {

        /**
         * 如果缺少，连类加载器都不能加载了，让其提前加载
         * FileNotFoundException: /Users/joyce/work/netty/netty-test/target/classes/com/jds/test/bio/p12/Client.class (Too many open files in system)
         */
        FileClient fileClient = new FileClient();
        TcpClient.run2();
        System.out.println("tcp done");
        Thread.sleep(5000);
        System.out.println("start file");
        FileClient.run();
    }

    /*
    ** 使命令行有足够时间操作
     */
    public static void zuse() {
        while (true) {
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}